<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JVM新生代垃圾回收机制</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .number-circle {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            flex-shrink: 0;
        }
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.3);
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #667eea, #764ba2, transparent);
            margin: 3rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center animate-fadeInUp">
            <h1 class="text-5xl md:text-6xl font-bold mb-6" style="font-family: 'Noto Serif SC', serif;">
                JVM新生代垃圾回收机制
            </h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto leading-relaxed">
                深入解析如何通过分区策略、数据结构优化和增量标记等技术，实现高效的局部垃圾回收，避免全堆扫描
            </p>
            <div class="mt-8 flex justify-center space-x-4">
                <div class="bg-white bg-opacity-20 rounded-full px-6 py-2 backdrop-filter backdrop-blur-sm">
                    <i class="fas fa-memory mr-2"></i>内存优化
                </div>
                <div class="bg-white bg-opacity-20 rounded-full px-6 py-2 backdrop-filter backdrop-blur-sm">
                    <i class="fas fa-tachometer-alt mr-2"></i>性能提升
                </div>
                <div class="bg-white bg-opacity-20 rounded-full px-6 py-2 backdrop-filter backdrop-blur-sm">
                    <i class="fas fa-cogs mr-2"></i>智能回收
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction Card -->
        <div class="content-card rounded-2xl shadow-xl p-8 mb-12 animate-fadeInUp">
            <div class="flex items-start">
                <i class="fas fa-lightbulb text-4xl text-gradient mr-6 mt-1"></i>
                <div>
                    <h2 class="text-2xl font-bold mb-4 text-gray-800">核心理念</h2>
                    <p class="text-lg text-gray-700 leading-relaxed">
                        JVM的新生代垃圾回收通过精心设计的策略，实现了对内存的高效管理。这些策略包括局部处理、数据结构优化和增量标记等方式，确保垃圾回收仅在必要的区域内进行，显著减少了全堆扫描的需求，从而大幅提升了系统性能。
                    </p>
                </div>
            </div>
        </div>

        <!-- Visualization -->
        <div class="content-card rounded-2xl shadow-xl p-8 mb-12 animate-fadeInUp" style="animation-delay: 0.2s;">
            <h2 class="text-2xl font-bold mb-6 text-center text-gray-800">垃圾回收策略架构图</h2>
            <div class="mermaid">
                graph TB
                    A[JVM堆内存] --> B[新生代]
                    A --> C[老年代]
                    B --> D[Eden区]
                    B --> E[Survivor区1]
                    B --> F[Survivor区2]
                    
                    G[垃圾回收策略] --> H[分区式回收]
                    G --> I[卡表机制]
                    G --> J[写屏障]
                    G --> K[分代算法]
                    G --> L[增量标记]
                    G --> M[虚拟内存管理]
                    
                    H -.-> B
                    I -.-> B
                    J -.-> B
                    
                    style A fill:#f9f,stroke:#333,stroke-width:2px
                    style G fill:#bbf,stroke:#333,stroke-width:2px
                    style B fill:#9f9,stroke:#333,stroke-width:2px
            </div>
        </div>

        <!-- Strategy Cards -->
        <div class="grid md:grid-cols-2 gap-8 mb-12">
            <!-- Strategy 1 -->
            <div class="content-card rounded-2xl shadow-xl p-8 card-hover animate-fadeInUp" style="animation-delay: 0.3s;">
                <div class="flex items-start mb-4">
                    <div class="number-circle">1</div>
                    <h3 class="text-2xl font-bold ml-4 text-gray-800">分区式垃圾回收</h3>
                </div>
                <p class="text-gray-700 mb-4 leading-relaxed">
                    新生代被精心划分为多个功能区域，实现了高效的内存管理：
                </p>
                <div class="space-y-3">
                    <div class="flex items-start">
                        <i class="fas fa-seedling text-green-500 mt-1 mr-3"></i>
                        <div>
                            <strong class="text-gray-800">Eden区：</strong>
                            <span class="text-gray-600">新对象的诞生地，所有对象最初都在这里分配内存</span>
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-shield-alt text-blue-500 mt-1 mr-3"></i>
                        <div>
                            <strong class="text-gray-800">Survivor区：</strong>
                            <span class="text-gray-600">经历垃圾回收后的幸存者暂居地，为晋升老年代做准备</span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Strategy 2 -->
            <div class="content-card rounded-2xl shadow-xl p-8 card-hover animate-fadeInUp" style="animation-delay: 0.4s;">
                <div class="flex items-start mb-4">
                    <div class="number-circle">2</div>
                    <h3 class="text-2xl font-bold ml-4 text-gray-800">卡表机制</h3>
                </div>
                <p class="text-gray-700 leading-relaxed">
                    卡表是一种精巧的数据结构，它像一本记录簿，详细记录着新生代中哪些内存区域被修改过。当对象被引用或修改时，相应的卡表条目会被即时更新。垃圾回收器通过查阅这本"记录簿"，精准定位需要扫描的区域，避免了盲目的全堆扫描。
                </p>
                <div class="mt-4 bg-purple-50 rounded-lg p-4">
                    <i class="fas fa-info-circle text-purple-600 mr-2"></i>
                    <span class="text-sm text-purple-700">卡表将内存划分为固定大小的卡片，每个卡片对应一个标记位</span>
                </div>
            </div>

            <!-- Strategy 3 -->
            <div class="content-card rounded-2xl shadow-xl p-8 card-hover animate-fadeInUp" style="animation-delay: 0.5s;">
                <div class="flex items-start mb-4">
                    <div class="number-circle">3</div>
                    <h3 class="text-2xl font-bold ml-4 text-gray-800">写屏障技术</h3>
                </div>
                <p class="text-gray-700 leading-relaxed">
                    写屏障如同一个智能监控系统，实时追踪对象在垃圾回收过程中的修改情况。它在对象被修改的瞬间记录下这一事件，使垃圾回收器在标记阶段能够聚焦于那些真正发生变化的区域，大幅减少了需要扫描的内存范围。
                </p>
                <div class="mt-4 flex items-center text-sm text-gray-600">
                    <i class="fas fa-bolt text-yellow-500 mr-2"></i>
                    写屏障在运行时几乎不影响程序性能
                </div>
            </div>

            <!-- Strategy 4 -->
            <div class="content-card rounded-2xl shadow-xl p-8 card-hover animate-fadeInUp" style="animation-delay: 0.6s;">
                <div class="flex items-start mb-4">
                    <div class="number-circle">4</div>
                    <h3 class="text-2xl font-bold ml-4 text-gray-800">分代收集算法</h3>
                </div>
                <p class="text-gray-700 leading-relaxed">
                    这是新生代垃圾回收的核心哲学。算法将内存空间按对象年龄划分，新生代和老年代各司其职。新生代的垃圾回收专注于处理年轻对象，这种"各管各家"的策略有效避免了对整个堆的扫描，让垃圾回收更加高效精准。
                </p>
                <div class="mt-4 bg-blue-50 rounded-lg p-4">
                    <i class="fas fa-chart-line text-blue-600 mr-2"></i>
                    <span class="text-sm text-blue-700">统计显示，98%的对象在新生代就会被回收</span>
                </div>
            </div>

            <!-- Strategy 5 -->
            <div class="content-card rounded-2xl shadow-xl p-8 card-hover animate-fadeInUp" style="animation-delay: 0.7s;">
                <div class="flex items-start mb-4">
                    <div class="number-circle">5</div>
                    <h3 class="text-2xl font-bold ml-4 text-gray-800">增量标记</h3>
                </div>
                <p class="text-gray-700 leading-relaxed">
                    增量标记将庞大的标记任务分解为多个小步骤，如同将一座大山分解为可以逐步攀登的小丘。这种方法避免了一次性扫描整个堆带来的长时间停顿，让垃圾回收过程更加平滑，用户体验更加流畅。
                </p>
                <div class="mt-4 flex items-center text-sm text-gray-600">
                    <i class="fas fa-puzzle-piece text-green-500 mr-2"></i>
                    增量标记特别适合对延迟敏感的应用场景
                </div>
            </div>

            <!-- Strategy 6 -->
            <div class="content-card rounded-2xl shadow-xl p-8 card-hover animate-fadeInUp" style="animation-delay: 0.8s;">
                <div class="flex items-start mb-4">
                    <div class="number-circle">6</div>
                    <h3 class="text-2xl font-bold ml-4 text-gray-800">虚拟内存管理</h3>
                </div>
                <p class="text-gray-700 leading-relaxed">
                    先进的JVM实现通过优化虚拟内存管理来进一步提升效率。通过精心调整堆的布局和分配策略，确保新生代的垃圾回收活动被严格限制在其管辖范围内，从根本上减少了不必要的内存扫描。
                </p>
                <div class="mt-4 bg-indigo-50 rounded-lg p-4">
                    <i class="fas fa-microchip